<template>
	<view class="Withdrawal">
		<view class="message_top">
			<view class="message_top_title" :style="{top:computedTop}">提现</view>
			<view class="message_top_back" :style="{top:computedTop}" @click="Back">
				<image src="../../static/search/back.png" class="bfbimages"></image>
			</view>
		</view>

		<view class="Withdrawal_box">
			<view class="Withdrawal_box_box">
				<view>
					<text>提现金额</text>
					<view>
						<text style="font-size: 52rpx;color: #11182F;">￥</text>
						<input type="text" style="font-size: 52rpx;color: #11182F;font-weight: bold;width: 370rpx;"
							v-model="withdraw_money" />
						<text style="font-size:26rpx;color: #FE4926;" @click="withdraw_money=price">全部转出</text>
					</view>
					<view style="width: 100%;height: auto;margin-top: 30rpx;font-size: 24rpx;color: #A7A7A7;border: 0;">
						可提现余额：{{price}}</view>
				</view>

				<view @click="Ok">确认提现</view>

				<view>
					<view style="width: 100%;height: auto;font-size: 28rpx;font-weight:bold;color: #11182F;">提现规则</view>
					<text style="display: inline-block;margin-top: 12rpx;">1、满100即可提现</text><br />
					<text style="display: inline-block;margin-top: 12rpx;">2、满100即可提现</text><br />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuButtonInfo: null,
				withdraw_money: '',
				price: 0
			}
		},
		computed: {
			computedTop() {
				if (this.menuButtonInfo) {
					return `${this.menuButtonInfo.height * 2 - 6}px`;
				}
				return '0px';
			},
		},
		onLoad() {
			const info = uni.getMenuButtonBoundingClientRect();
			this.menuButtonInfo = info;
		},
		onShow() {
			this.Info()
		},
		methods: {
			Info() {
				this.$request('/api/user/getUser').then((res) => {
					console.log(res.data, '个人信息');
					this.price = res.data.balance
				})
			},
			Ok() {
				let data = {
					withdraw_money: this.withdraw_money
				}
				this.$request('/api/user/applyWithdraw', data).then((res) => {
					console.log(res, '提现');
					if (res.code == 1) {
						this.withdraw_money=''
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1500
						});
						this.Info()
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1500
						});
						return
					}
				})
			},
			Back() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	.Withdrawal {
		width: 100vw;
		height: 100vh;
		float: left;

		.message_top {
			width: 100%;
			height: 230rpx;
			position: relative;
			background-color: #FFE9D4;

			.message_top_title {
				width: 100%;
				text-align: center;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				position: absolute;
				left: 0;
				z-index: 2;
			}

			.message_top_back {
				width: 44rpx;
				height: 44rpx;
				position: absolute;
				left: 30rpx;
				z-index: 9;
			}
		}

		.Withdrawal_box {
			width: 100%;
			height: calc(100vh - 230rpx);
			position: relative;

			.Withdrawal_box_box {
				width: 100%;
				height: 100%;
				position: absolute;
				left: 0;
				top: -30rpx;
				border-top-right-radius: 30rpx;
				border-top-left-radius: 30rpx;
				background-color: #FFFFFF;
				z-index: 6;
				float: left;
			}

			.Withdrawal_box_box>view:nth-child(1) {
				width: 610rpx;
				margin: 62rpx auto 0;
			}

			.Withdrawal_box_box>view:nth-child(1)>text:nth-child(1) {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}

			.Withdrawal_box_box>view:nth-child(1)>view {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 100%;
				height: 100rpx;
				border-bottom: 2rpx solid #000000;
				margin: 5rpx auto 0;
			}

			.Withdrawal_box_box>view:nth-child(2) {
				width: 610rpx;
				height: 100rpx;
				background: linear-gradient(270deg, #FE4624 0%, #FF8143 100%);
				border-radius: 60rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 100rpx;
				margin: 130rpx auto 0;
			}

			.Withdrawal_box_box>view:nth-child(3) {
				width: 610rpx;
				height: auto;
				margin: 60rpx auto 0;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #878787;
			}
		}
	}
</style>